package com.sky.config;

import com.sky.properties.MinioProperties;
import com.sky.utils.MinioUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 配置类：用于创建MinioUtil对象
 */
@Configuration
@Slf4j
public class MinioConfiguration {

    @Bean
    @ConditionalOnMissingBean
    public MinioUtil minioUtil(MinioProperties properties) {
        log.info("开始创建Minio文件上传工具类对象：{}", properties);
        return new MinioUtil(properties.getEndpoint(),
                      properties.getAccessKey(),
                      properties.getSecretKey(),
                      properties.getBucketName());

    }

}
